using System;
using Headspring.Training.Core.Model;
using Headspring.Training.Core.Services;
using Headspring.Training.Core.Services.Impl;
using NUnit.Framework;
using NUnit.Framework.SyntaxHelpers;
using Rhino.Mocks;

namespace Headspring.Training.UnitTests.Services
{
	[TestFixture]
	public class WorkOrderBuilderTester
	{
		[Test]
		public void ShouldCorrectlyBuildAWorkOrder()
		{
			var generator = MockRepository.GenerateMock<IWorkOrderNumberGenerator>();
			ICalendar calendar = new StubbedCalendar(new DateTime(2000, 1, 1));
			generator.Expect(x => x.GenerateNumber()).Return("124");

			var builder = new WorkOrderBuilder(generator, calendar);
			var creator = new Employee();
			WorkOrder workOrder = builder.CreateNewWorkOrder(creator);

			generator.VerifyAllExpectations();
			Assert.That(workOrder.Creator, Is.EqualTo(creator));
			Assert.That(workOrder.Number, Is.EqualTo("124"));
			Assert.That(workOrder.CreatedDate, Is.EqualTo(new DateTime(2000, 1, 1)));
			Assert.That(workOrder.Assignee, Is.Null);
			Assert.That(workOrder.Title, Is.Empty);
			Assert.That(workOrder.Description, Is.Empty);
			Assert.That(workOrder.Status, Is.EqualTo(WorkOrderStatus.Draft));
		}
	}
}